package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;

public class BibliotecaApp {
    private PrintStream printer;
    private String userInput = "";
    private WelcomeMenu welcomeMenu;
    private UserInputReader userInputReader;
    private Library library;
    private OptionParser optionParser;


    public BibliotecaApp(PrintStream printer) {
        this.printer = printer;
        welcomeMenu = new WelcomeMenu(System.out);
        userInputReader = new UserInputReader(new BufferedReader(new InputStreamReader(System.in)));
        library = new Library(printer, new ArrayList<String>());
        optionParser = new OptionParser(library, printer);

    }


    public void run() {
        welcomeMenu.welcomeMessage();
        boolean option = true;
        while(option){

            welcomeMenu.menu();
            userInput = userInputReader.readUserInput();
            if(userInput.equals("quit"))
                option = false;
            optionParser.checkOptionValidity(userInput);
            if ((this.userInput).equals("2")) {
                userInputReader.readUserInput();
                library.checkBookAvailability(userInput);
            }
        }


    }
}
